package com.example.volleydemo;

import java.util.Map;

import com.android.volley.AuthFailureError;
import com.android.volley.Request.Method;
import com.android.volley.toolbox.StringRequest;

import android.content.Context;

public class VolleyRequest {
	public static void stringRequestPost(Context context,String url,String tag,final Map<String, String> params,VolleyInterface vif) {
		MyApplication.getRequestQueue().cancelAll(tag);
		StringRequest request=new StringRequest(Method.POST,url, vif.getListener(),vif.getErrorListener()){
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				return params;
			}
		};
		request.setTag(tag);
		MyApplication.getRequestQueue().add(request);
		MyApplication.getRequestQueue().start();
	}
	public static void stringRequestGet(Context context,String url,String tag,VolleyInterface vif) {
		
		MyApplication.getRequestQueue().cancelAll(tag);
		StringRequest request=new StringRequest(Method.GET,url, vif.getListener(),vif.getErrorListener());
		request.setTag(tag);
		MyApplication.getRequestQueue().add(request);
		MyApplication.getRequestQueue().start();
	}
}
